package univ.lille1.fr.rest;

import java.io.File;

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.Response.ResponseBuilder;

@Path("/document")
public class GetFileService {

	@GET
	@Path("/{file}")
	@Produces("text/plain")
	public Response getFile(@PathParam("file") String file){
		File downloaded_file = new File(file);
		 
		ResponseBuilder response = Response.ok((Object) downloaded_file);
		response.header("Content-Disposition",
			"attachment; filename=\""+ file +"\"");
		return response.build();
	}
	
}
